package com.afalon.cloud.contracts.finance;

import java.math.BigDecimal;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable
@XmlRootElement(name = "transaction")
@XmlAccessorType(XmlAccessType.NONE)
public class Transaction 
{
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key transactionKey;
	
	@XmlElement
	@Persistent
	private String dateTime;
	
	@XmlElement
	@Persistent
	private BigDecimal totalValue;
	
	@Persistent
	private Budget budget;
	
	@Persistent
	private Chart chart;
	
	@Persistent(mappedBy = "transaction")
    private List<TransactionLine> transactionLines;

	public Transaction() 
	{
		
	}

	public Key getTransactionKey() {
		return transactionKey;
	}

	@XmlElement
	public String getTransactionId() {
		return KeyFactory.keyToString(this.getTransactionKey());
	}

	public void setDatetime(String value) {
		dateTime = value;
	}

	public String getDatetime() {
		return dateTime;
	}
	
	public void setTotalvalue(BigDecimal value) {
		totalValue = value;
	}

	public BigDecimal getTotalvalue() {
		return totalValue;
	}
	
	@XmlElement
	public String getBudgetId() {
		return budget.getBudgetId();
	}
	
	@XmlElement
	public String getChartId() {
		return chart.getChartId();
	}

	public List<TransactionLine> getTransactionLines() {
		return transactionLines;
	}
	
}
